import config from 'config'
import httpFetch from 'share/httpFetch'

export default {

  //信用模型列表
  getCreditModelList(params){
    return httpFetch.get(`${config.baseUrl}/api/credit/model`, params)
  },

  //保存信用模型
  saveCreditModel(creditModel){
    return httpFetch.post(`${config.baseUrl}/api/credit/model`, creditModel)
  },

  //根据id得到信用模型
  getCreditModel(id){
    return httpFetch.get(`${config.baseUrl}/api/credit/${id}/model`)
  },

  //信用模型内的信用分级
  getCreditRank(modelId){
    return httpFetch.get(`${config.baseUrl}/api/credit/rank`, { modelId })
  },

  //信用模型是否可用
  getCreditValid(modelId){
    return httpFetch.get(`${config.baseUrl}/api/credit/invalid/model/${modelId}`)
  },

  //保存信用分级
  saveCreditRank(rank){
    return httpFetch.post(`${config.baseUrl}/api/credit/rank`, rank)
  },

  //信用规则集
  getCreditRulesGroups(params){
    return httpFetch.get(`${config.baseUrl}/api/credit/rule/set`, params)
  },

  //保存信用规则集
  saveCreditRulesGroup(params){
    return httpFetch.post(`${config.baseUrl}/api/credit/rule/set`, params)
  },

  //得到信用模型分配的公司
  getCreditCompany(id ,params){
    return httpFetch.get(`${config.baseUrl}/api/credit/${id}/company`, params)
  },

  //得到信用模型未分配的公司
  getUnselectedCompany(id){
    return httpFetch.get(`${config.baseUrl}/api/credit/${id}/stay/company`)
  },

  //信用模型分配公司
  assignCompany(id, params){
    return httpFetch.post(`${config.baseUrl}/api/credit/${id}/company`, params)
  },

  //根据id得到信用规则集
  getCreditRulesGroup(id){
    return httpFetch.get(`${config.baseUrl}/api/credit/rule/set/${id}`)
  },

  //根据规则集id得到规则
  getCreditRules(id, params){
    return httpFetch.get(`${config.baseUrl}/api/credit/rule/${id}/condition`, params)
  },

  //保存规则
  saveCreditRule(id, params){
    return httpFetch.post(`${config.baseUrl}/api/credit/rule/${id}/condition`, params)
  },

  //下载模板
  getCreditExport(){
    return httpFetch.get(`${config.baseUrl}api/credit/user/template/export`)
  },

  //导入用户信用分接口：
  postCreditImport(params){
    return httpFetch.post(`${config.baseUrl}/api/credit/user/score/import`, params)
  },

  //错误信息导出接口：
  getCreditImportError(transactionOID){
    return httpFetch.get(`${config.baseUrl}/api/credit/failed/export/${transactionOID}`)
  },
}
